package com.nd.mobile.study.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import android.os.Bundle;

import com.fuckhtc.gson.Gson;
import com.fuckhtc.gson.annotations.SerializedName;
import com.fuckhtc.gson.reflect.TypeToken;
import com.nd.mobile.study.common.config.Commands;
import com.nd.mobile.study.common.config.ReqParam;
import com.nd.mobile.study.common.util.HttpRequestUtil;

public class HomeworkInfo implements Serializable{

	private static final long	serialVersionUID	= 1L;
	@SerializedName("SOID")
	private String id;
	@SerializedName("OperationTitle")
	private String title;
	@SerializedName("OperationNote")
	private String note;
	
	private String answer;
	
	private Bundle prepareReq(User user) {
		Bundle data = new Bundle();
		data.putString(ReqParam.SOID, this.id);
		data.putString(ReqParam.SOTITLE, this.title);
		data.putString(ReqParam.SONOTE, this.answer);
		data.putString(ReqParam.COMMON_USER_ID, user.getUserId());
		return data;
	}
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getNote() {
		return note;
	}
	public void setNote(String note) {
		this.note = note;
	}
	public String getAnswer() {
		return answer;
	}

	public void setAnswer(String answer) {
		this.answer = answer;
	}
	/***
	 * 发送答案
	 * @param user
	 * @return
	 * @throws Exception
	 */
	public Result sendHomeworkAnser(User user)  throws Exception{
		String jsonData = HttpRequestUtil.get(Commands.SUBMIT_SUBJECT_HOMEWORK_A, prepareReq(user));
		Result<String> result = new Gson().fromJson(jsonData, new TypeToken<Result<String>>() {
		}.getType());
		return result;
	}

	
	
}
